<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong> {{ sheng }} </strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: smm === 'all' }"
          @click="Dll('all')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: smm === 'active' }"
          @click="Dll('active')"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: smm === 'over' }"
          @click="Dll('over')"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-show="overFn" @click="out">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  props: {
    arr: {
      tyoe: Array,
      required: true,
    },
  },
  data() {
    return {
      smm: "all",
    };
  },
  methods: {
    //清除
    out() {
      this.$emit("out");
    },
    //高亮显示
    Dll(val) {
      this.smm = val;
      this.$emit("Dll", val);
    },
  },
  computed: {
    //计算剩余
    sheng() {
      return this.arr.filter((item) => item.isDone === false).length;
    },
    //计算显示
    overFn() {
      return this.arr.some((item) => item.isDone === true);
    },
  },
};
</script>
